package com.bangdream.michelia.view.adapter;



import android.annotation.SuppressLint;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

import com.bangdream.michelia.R;
import com.bangdream.michelia.entity.TaskCurriculumBean;
import com.bangdream.michelia.entity.courses.CoursesBean;
import com.bangdream.michelia.utils.ImageLoadUtils;
import com.bangdream.michelia.utils.StausUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.nanchen.compresshelper.StringUtil;

/**
 * Created by zhouyi on 2018/3/25.
 */

public class CourseTypeAdapter extends BaseQuickAdapter<TaskCurriculumBean,BaseViewHolder> {
    public CourseTypeAdapter(int layoutResId) {
        super(layoutResId);
    }
    private Drawable selectBg,selectedBg;
    private int selectTextColor,selectedTextColor;

    @Override
    protected void convert(BaseViewHolder helper, TaskCurriculumBean item) {

        selectTextColor =mContext.getResources().getColor(R.color.text_color);
        selectedTextColor = mContext.getResources().getColor(R.color.common_red);
        selectBg = mContext.getResources().getDrawable(R.drawable.cutting_gray_line);
        selectedBg = mContext.getResources().getDrawable(R.drawable.cutting_red_line_bg);


        ImageLoadUtils.ImageLoad(mContext,item.getFaceUrl(),(ImageView) helper.getView(R.id.ivIcon),R.mipmap.kecheng);
        helper.setText(R.id.tvTitle,item.getName()+"");
        helper.setText(R.id.tvContent,item.getTitle()+"");
        helper.setText(R.id.tvCollection,item.getCollectCount()+"");
        helper.setText(R.id.tvZan,item.getLearnCount()+"");
        helper.setText(R.id.tvPeopleNumber,item.getLearnCount()+"");

        if(!StringUtil.isEmpty(item.getCollectId())){
            helper.getView(R.id.btnCollection).setBackground(selectedBg);
            helper.setTextColor(R.id.tvCollection,selectedTextColor);
            helper.setImageResource(R.id.ivCollection,R.mipmap.rw_zan_icon_on);
        }else {
            helper.getView(R.id.btnCollection).setBackground(selectBg);
            helper.setTextColor(R.id.tvCollection,selectTextColor);
            helper.setImageResource(R.id.ivCollection,R.mipmap.icon_collection1);

        }

        if(item.getLearnStatus()!=null) {
            helper.setVisible(R.id.tvState,true);
            helper.setText(R.id.tvState,StausUtils.coursesStateToText(item.getLearnStatus()));
        }else {
            helper.setGone(R.id.tvState,true);
        }

    }
}
